/**
 * 
 */
package refect;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;

/**
 * @author Michael
 *
 */
public class ReflectTest {

	public static Car initByDefaultConst() throws Throwable {
		ClassLoader loader = Thread.currentThread().getContextClassLoader();
		Class<?> clazz = loader.loadClass("reflect.Car");
		Class<?> clazz1 = Class.forName("relect.Car", false, Thread.currentThread().getContextClassLoader());
		
		Constructor cons = clazz.getDeclaredConstructor((Class[])null);
		Object obj = cons.newInstance();
		
		Method setBrand = clazz.getMethod("setBrand", String.class);
		setBrand.invoke(obj, "BMW");
		Method setColor = clazz.getMethod("setColor", String.class);
		setColor.invoke(obj, "black");
		Method setMaxSpeed = clazz.getDeclaredMethod("setMaxSpeed", Integer.class);
		
		return null;
	}
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}

}
